$(document).ready(function() {
	$("#login_img").click(function() {
		$.ajax({
			type : "POST",
			url : "mycinema.do",
			data : $("#loginForm").serialize(),
			dataType:"json",
			success:function(js){
				if(js.map.fail=="N"){
					alert("아이디가 존재하지 않거나 비밀번호가 일치하지 않습니다!");
					$("#id").val("");
					$("#password").val("");
				}else{
					loginMember(js.map.vo.name,js.map.vo.memberlevelinfoVO.member_level_no);
				}
			},
			error:function(){
				alert('error join..');
			}
		}); //ajax
	}); // #login_img click
	$("#logout_img").on("click",function(){
		if(confirm("로그아웃 하시겠습니까?"))
			location.href="mycinema.do?command=logout";
		
	});// #logout_img click
});
function loginMember(name,level){
	var table="<table border='0' width='400' border='0' cellspacing='0' cellpadding='0'><tr>";
	table+="<td width='30'  align='right'><img src='img/header_login_ok.gif' border='0'></td>";
	table+="<td width='100'  align='center'>"+name+"님 반갑습니다.</td>";
	table+="<td width='10'  align='center'><img id='logout_img' src='img/header_logout_btn.gif' border='0' style='cursor: pointer;'/></td>";
	if(level==1)
		document.getElementById("admin_menu").innerHTML="<a href='admin.do?command=main_admin'><img src='img/header_menu5.png' border='0' onMouseOver=this.src='img/header_menu5_over.png' onMOuseOut=this.src='img/header_menu5.png'></a>";
	table+="</tr></table>";
	 $("#login").html(table); 
	 location.href="mycinema.do?command=home_main";
}